import router from '@/router';
import store from "@/store";
import {
    Toast
} from 'vant';
router.beforeEach(async (to, from, next) => {
    if (to.path == '/cart') {
        try {
            let p = await store.dispatch('GetUserInfo');
            console.log(p.flag);
            if (p.flag) {
                //验证token，通过
                next();
            } else {
                Toast('购物车需要登录！');
                next('/login/phone');
            }
        } catch (err) {
            console.log(err);
        }
    } else {
        next();
    }
});